package com.zone.types.exception;

import com.zone.types.enums.ResponseCode;

/**
 * @author: zongzi
 * @description: 自定义业务异常
 * @date: 2024/6/18
 */
public class BizException extends RuntimeException {
    // 响应吗
    private final ResponseCode responseCode;
    // 异常描述
    private final String errorMsg;

    public BizException() {
        super(ResponseCode.BIZ_ERROR.getInfo());
        this.responseCode = ResponseCode.BIZ_ERROR;
        this.errorMsg = ResponseCode.BIZ_ERROR.getInfo();
    }

    public BizException(String errorMsg, Object... params) {
        super(errorMsg);
        this.responseCode = ResponseCode.BIZ_ERROR;
        this.errorMsg = String.format(errorMsg, params);
    }

    public BizException(String errorMsg) {
        super(errorMsg);
        this.responseCode = ResponseCode.BIZ_ERROR;
        this.errorMsg = errorMsg;
    }

    public BizException(ResponseCode responseCode, String errorMsg) {
        super(errorMsg);
        this.responseCode = responseCode;
        this.errorMsg = errorMsg;
    }

    public ResponseCode getResponseCode() {
        return responseCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }
}
